/*
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class buttonExecutionClass_Test {

    static testMethod void myUnitTest() 
    {
        // TO DO: implement unit test
        string result = null;
        
        Location__c locationObject1 = new Location__c();
        locationObject1.Name = 'Test Office';
        locationObject1.Location_Type__c = 'Office';
        locationObject1.Rental_Rate__c = 18000;
        insert locationObject1;
        
        //For Location Object Records...
        Location__c locationObject2 = new Location__c();
        locationObject2.Name = 'Test Land';
        locationObject2.Location_Type__c = 'Land';
        locationObject2.Rental_Rate__c = 18000;
        insert locationObject2;
        
        Location__c locationObject3 = new Location__c();
        locationObject3.Name = 'Test SM-Office';
        locationObject3.Location_Type__c = 'SM-Office';
        locationObject3.Rental_Rate__c = 18000;
        insert locationObject3;
        
        Location__c locationObject4 = new Location__c();
        locationObject4.Name = 'Test SM-Office1232';
        locationObject4.Location_Type__c = 'SM-Office';
        locationObject4.Rental_Rate__c = 18000;
        insert locationObject4;
        
        //Account Object Record...
        Account accountObject = new Account();
        accountObject.Name = 'Test Account';
        //accountObject.LicenseNumber__c = serialObject.id;
        accountObject.License_Application_Step__c = 'Record Created';
        accountObject.License_Application_Type__c = 'New License';
        accountObject.Activity__c = 'Trading - One Activity';
        accountObject.License_Issue_Date__c = system.today();
        accountObject.License_Expiry_Date__c = System.Today().addYears(1);
        accountObject.Master_Account_Flag__c = true;
        accountObject.Mobile__c = '971504543558';
        
        insert accountObject;
        
          //For Location booking Objects Records...
        Location_Booking_Information__c locationBookingObject1 = new Location_Booking_Information__c();
        locationBookingObject1.Account__c = accountObject.id;
        locationBookingObject1.Location__c = locationObject1.Id;
        locationBookingObject1.License_Booking_Status__c = 'Booked';
        insert locationBookingObject1;
        
        Location_Booking_Information__c locationBookingObject2 = new Location_Booking_Information__c();
        locationBookingObject2.Account__c = accountObject.id;
        locationBookingObject2.Location__c = locationObject2.Id;
        locationBookingObject2.License_Booking_Status__c = 'Booked';
        insert locationBookingObject2;
        
         //For Contact Object Records...
        Contact contactObject1 = new Contact();
        contactObject1.LastName = 'Test 1 Manager';
        contactObject1.AccountId = accountObject.id;
        contactObject1.Current_Employer__c =accountObject.id;
        contactObject1.Contact_Type__c = 'Manager';
        insert contactObject1;
        
        //For Passport History...
        Passport_History__c passportObject = new Passport_History__c();
        passportObject.Passport_Holder__c = contactObject1.Id;
        passportObject.Passport_Number__c = '123234545';
        insert passportObject;
        
        
        //For Passport History...
        Passport_History__c passportObject1 = new Passport_History__c();
        passportObject1.Passport_Holder__c = contactObject1.Id;
        passportObject1.Passport_Number__c = '123234545';
        passportObject1.isCurrent__c = true;
        
        insert passportObject1;
        
        //For Visa History...
        Visa_History__c visaObject = new Visa_History__c();
        visaObject.Visa_Holder__c = contactObject1.Id;
        visaObject.Sponsor__c = accountObject.Id;
        insert visaObject;   
             
        //For Suspension Object Records...
        Fines__c fineObject = new Fines__c();
        fineObject.Issue_Date__c = System.today();
        fineObject.Account__c = accountObject.id;
        fineObject.Fine_Type__c = 'Fix Amount';
        fineObject.Fine_Amount__c = 1000;
        fineObject.Fines_Included__c = true;
        fineObject.Status__c = 'Approved';
        insert fineObject;
        
        //For Tenancy Object Records...
        RecordType recordType = [select Id,IsActive,SObjectType,DeveloperName from RecordType where DeveloperName = 'New_Tenancy_Contract' AND SObjectType = 'Tenancy_Contract__c'];
        Tenancy_Contract__c tenancyObject = new Tenancy_Contract__c();
        tenancyObject.Location__c = locationObject2.id;
        tenancyObject.RecordTypeId = recordType.id;
        tenancyObject.Tenant__c = accountObject.id;
        tenancyObject.Tenancy_Contract_Start_Date__c = accountObject.License_Issue_Date__c;
        tenancyObject.Tenancy_Contract_Expiry_Date__c = date.TODAY().addyears(1).adddays(-1);
        insert tenancyObject;
        
        //For Update the Location with the current Locaiton...
        locationObject2.Current_Tenancy_Contract__c = tenancyObject.Id;
        update locationObject2;
        
        
        Map<string,RecordType> amendmentRecordTypeMap = new Map<string,RecordType>();
        for(RecordType tempObject : [SELECT Id,SObjectType,DeveloperName,IsActive FROM RecordType where SObjectType =: 'Amendment__c' AND IsActive =: true])
        {
            amendmentRecordTypeMap.put(tempObject.DeveloperName, tempObject);
            
        }
        
        
        //For Amendment Object For Company Name...
        Amendment__c amendmentObject = new Amendment__c();
        amendmentObject.RecordTypeId = amendmentRecordTypeMap.get('Company_Amendment_Change_Company_Name').Id;
        amendmentObject.Account__c = accountObject.Id;
        amendmentObject.New_Company_Name__c = 'Test New Name';
        amendmentObject.New_Company_Name_Arabic__c = 'test New Name Arabic';
        //amendmentObject.Chamber_History__c = chamberObject.id;
        insert amendmentObject;
        
        //For Amendment Object For Company Name...
        Amendment__c amendmentObject1 = new Amendment__c();
        amendmentObject1.RecordTypeId = amendmentRecordTypeMap.get('Location_Amendment_Add_Location').Id;
        amendmentObject1.Account__c = accountObject.Id;
        amendmentObject1.New_Location__c = locationObject1.Id;
        amendmentObject1.New_Location_2__c = locationObject2.Id;
        amendmentObject1.New_Location_3__c = locationObject3.Id;
        insert amendmentObject1;
        
         //Now For Account Locations ....
        Account_Location__c accountLocationObject1 = new Account_Location__c();
        accountLocationObject1.Account__c = accountObject.Id;
        accountLocationObject1.Previous_Location__c = locationObject1.Id;
        accountLocationObject1.Previous_Tenancy_Contract__c = tenancyObject.Id;
        insert accountLocationObject1;
        
        Account_Location__c accountLocationObject2 = new Account_Location__c();
        accountLocationObject2.Account__c = accountObject.Id;
        accountLocationObject2.New_Location__c = locationObject4.Id;
        insert accountLocationObject2;
        
        
        //For Payment Plans...
        List<Payment_Plan__c> paymentList = new List<Payment_Plan__c>();
        
        Payment_Plan__c paymentObject1 = new Payment_Plan__c();
        paymentObject1.Action__c = 'Discount';
        paymentObject1.Installment__c = '1';
        paymentObject1.Percent__c = 10;
        paymentObject1.isActive__c = true;
        paymentObject1.License_Application_Type__c = 'New License';
        paymentObject1.Location_Type__c = 'Office';
        //Adding in the List...
        paymentList.add(paymentObject1);
        
        Payment_Plan__c paymentObject2 = new Payment_Plan__c();
        paymentObject2.Action__c = 'Discount';
        paymentObject2.Installment__c = '1';
        paymentObject2.Percent__c = 10;
        paymentObject2.isActive__c = true;
        paymentObject2.License_Application_Type__c = 'New License';
        paymentObject2.Location_Type__c = 'Land';
        //Adding in the List...
        paymentList.add(paymentObject2);
        
        Payment_Plan__c paymentObject3 = new Payment_Plan__c();
        paymentObject3.Action__c = 'Discount';
        paymentObject3.Installment__c = '1';
        paymentObject3.Percent__c = 10;
        paymentObject3.isActive__c = true;
        paymentObject3.License_Application_Type__c = 'New License';
        paymentObject3.Location_Type__c = 'SM-Office';
        //Adding in the List...
        paymentList.add(paymentObject3);
        
        
        Payment_Plan__c paymentObject4 = new Payment_Plan__c();
        paymentObject4.Action__c = 'Discount';
        paymentObject4.Installment__c = '1';
        paymentObject4.Percent__c = 10;
        paymentObject4.isActive__c = true;
        paymentObject4.License_Application_Type__c = 'Renewal';
        paymentObject4.Location_Type__c = 'Office';
        //Adding in the List...
        paymentList.add(paymentObject4);
        
        Payment_Plan__c paymentObject5 = new Payment_Plan__c();
        paymentObject5.Action__c = 'Discount';
        paymentObject5.Installment__c = '1';
        paymentObject5.Percent__c = 10;
        paymentObject5.isActive__c = true;
        paymentObject5.License_Application_Type__c = 'Renewal';
        paymentObject5.Location_Type__c = 'Land';
        //Adding in the List...
        paymentList.add(paymentObject5);
        
        Payment_Plan__c paymentObject6 = new Payment_Plan__c();
        paymentObject6.Action__c = 'Discount';
        paymentObject6.Installment__c = '1';
        paymentObject6.Percent__c = 10;
        paymentObject6.isActive__c = true;
        paymentObject6.License_Application_Type__c = 'Renewal';
        paymentObject6.Location_Type__c = 'SM-Office';
        //Adding in the List...
        paymentList.add(paymentObject6);
        
        
        Payment_Plan__c paymentObject7 = new Payment_Plan__c();
        paymentObject7.Action__c = 'Discount';
        paymentObject7.Installment__c = '1';
        paymentObject7.Percent__c = 10;
        paymentObject7.isActive__c = true;
        paymentObject7.License_Application_Type__c = 'Renewal Amendment';
        paymentObject7.Location_Type__c = 'Office';
        //Adding in the List...
        paymentList.add(paymentObject7);
        
        Payment_Plan__c paymentObject8 = new Payment_Plan__c();
        paymentObject8.Action__c = 'Discount';
        paymentObject8.Installment__c = '1';
        paymentObject8.Percent__c = 10;
        paymentObject8.isActive__c = true;
        paymentObject8.License_Application_Type__c = 'Renewal Amendment';
        paymentObject8.Location_Type__c = 'Land';
        //Adding in the List...
        paymentList.add(paymentObject8);
        
        Payment_Plan__c paymentObject9 = new Payment_Plan__c();
        paymentObject9.Action__c = 'Discount';
        paymentObject9.Installment__c = '1';
        paymentObject9.Percent__c = 10;
        paymentObject9.isActive__c = true;
        paymentObject9.License_Application_Type__c = 'Renewal Amendment';
        paymentObject9.Location_Type__c = 'SM-Office';
        //Adding in the List...
        paymentList.add(paymentObject9);
        
        Payment_Plan__c paymentObject10 = new Payment_Plan__c();
        paymentObject10.Action__c = 'Discount';
        paymentObject10.Installment__c = '1';
        paymentObject10.Percent__c = 10;
        paymentObject10.isActive__c = true;
        paymentObject10.License_Application_Type__c = 'Amendment';
        paymentObject10.Location_Type__c = 'Office';
        //Adding in the List...
        paymentList.add(paymentObject10);
        
        Payment_Plan__c paymentObject11 = new Payment_Plan__c();
        paymentObject11.Action__c = 'Discount';
        paymentObject11.Installment__c = '1';
        paymentObject11.Percent__c = 10;
        paymentObject11.isActive__c = true;
        paymentObject11.License_Application_Type__c = 'Amendment';
        paymentObject11.Location_Type__c = 'Land';
        //Adding in the List...
        paymentList.add(paymentObject11);
        
        Payment_Plan__c paymentObject12 = new Payment_Plan__c();
        paymentObject12.Action__c = 'Discount';
        paymentObject12.Installment__c = '1';
        paymentObject12.Percent__c = 10;
        paymentObject12.isActive__c = true;
        paymentObject12.License_Application_Type__c = 'Amendment';
        paymentObject12.Location_Type__c = 'SM-Office';
        //Adding in the List...
        paymentList.add(paymentObject12);
        
        
        //Inserting the List...
        insert paymentList;
        
        //For Button Execution Class Test Coverage...
        result = buttonExecutionClass.submitForManagerApproval(accountObject.Id);
        result = buttonExecutionClass.validateForAmendment(accountObject.Id);
        result = buttonExecutionClass.cancelLicenseMethod(accountObject.Id);
        result = buttonExecutionClass.validateForAccountLicensePDFButton(accountObject.Id);
        
        
        
        result = buttonExecutionClass.amendmentEmailNotificationLicenseMethod(amendmentObject.id);
        result = buttonExecutionClass.cancelEmailNotificationLicenseMethod(accountObject.Id);
        result = buttonExecutionClass.amendmenLicenseIssuedMethod(amendmentObject.Id);
        result = buttonExecutionClass.amendmenPerformaInvoiceMethod(amendmentObject.Id);
        
        result = buttonExecutionClass.dropLocationMethod(locationObject2.Id);
        result = buttonExecutionClass.underVacantLocationMethod(locationObject2.Id);
        result = buttonExecutionClass.unDropLocationMethod(locationObject2.Id);
        
        result = buttonExecutionClass.markPassportCurrent(passportObject.Id);
        result = buttonExecutionClass.markVisaCurrent(visaObject.Id);
        
        result = buttonExecutionClass.visaValuesCalculationsMethod(accountObject.Id);
        
        
        //Now Payment Plan Methods....
        result = buttonExecutionClass.canPaymentPlanImplementMethpd(accountObject.Id , 'New License');
        result = buttonExecutionClass.canPaymentPlanImplementMethpd(tenancyObject.Id , 'Tenancy');
        result = buttonExecutionClass.canPaymentPlanImplementMethpd(accountObject.Id , 'Renewal');
        result = buttonExecutionClass.canPaymentPlanImplementMethpd(amendmentObject1.Id , 'Amendment');
        result = buttonExecutionClass.canPaymentPlanImplementMethpd(accountObject.Id , 'Renewal Amendment');
        
        
        
        //todo
        //create custom settings
        Aramex_Integration__c aramex = new Aramex_Integration__c();
        aramex.AccountCountryCode__c = 'UAE';
        aramex.AccountEntity__c ='DXB';
        aramex.AccountNumber__c = '11';
        aramex.AccountPin__c = '22';
        aramex.AFZA_Address_Line1__c = 'Test 1';
        aramex.AFZA_Address_Line2__c = 'Test 2';
        aramex.AFZA_Department__c = 'Dept';
        aramex.AFZA_Person_Email__c = 'test@salesforce.com';
        aramex.AFZA_Person_Name__c = 'robin williams';
        aramex.AFZA_Person_Title__c = 'comedian';
        aramex.AFZA_Address_City__c = 'test city';
        aramex.AFZA_Address_Country__c = 'UAE';
        aramex.AFZA_Address_State__c = 'test';
        aramex.CellPhone__c = '3234';
        aramex.CompanyName__c = 'AFZ';
        aramex.FaxNumber__c = '32';
        aramex.Password__c = 'sd';
        aramex.PhoneNumber1__c ='123';
        aramex.PhoneNumber1Ext__c ='231';
        aramex.PhoneNumber2__c = '23';
        aramex.PhoneNumber2Ext__c = '343';
        aramex.UserName__c = 'test@salesforce.com';
        aramex.Version__c = '1.0';
        aramex.Name ='Aramex1';   
        insert aramex;
        
        
        //create transaction types
        Transaction_Types__c transType = new Transaction_Types__c();
        transType.Name = 'Bank Letter - Open Bank Account';
        transType.Application_Type__c = 'Bank Letter';
        insert transType;

        //create bank name
        Requested_For__c reqFor = new Requested_For__c();
        reqFor.Name = 'PO Bank';
        reqFor.Type__c = 'Banks';
        insert reqFor;

        //create request
        //get all record types
        Map<String, Id> recordMap = new Map<String, Id>();
        for(RecordType rec : [select Id, DeveloperName from RecordType where SObjectType = 'Request__c']){
        	recordMap.put(rec.developerName, rec.id);
        }
        
        Request__c req = new Request__c();
        req.Company__c = accountObject.id;
        req.Transaction_Type__c = transType.id;
        req.Courier_Delivery_Address__c = 'test1';
        req.Courier_Delivery_City__c = 'test city';
        req.Full_Name_English__c = 'test';
        req.Company_Name_English__c = 'test';
        req.Courier_Delivery_Contact_Mobile__c = '971504543558';
        req.Email__c = 'test@salesforce.com';
        req.Requested_For__c = reqFor.id;
        req.PRO_Mobile_No__c = '971504543558';
        //req.PRO_SMS_Address__c = 'porquillo@cloudconceptgroup.com';
        insert req;
        
        //call serviceLetterCreatePickupButton button
        //pass service letter id
        buttonExecutionClass.serviceLetterCreatePickupButton(req.Id);
        buttonExecutionClass.serviceLetterRefreshCourierstatusButton(req.Id);
        buttonExecutionClass.serviceLetterConfirmLetterSignedButton(req.Id);
        
        //pre aramex
        buttonExecutionClass.serviceLetterApproveButton(req.Id);
        req.recordTypeId = recordMap.get('Request_Service_Letter_Amendment');
        update req;
        buttonExecutionClass.serviceLetterApproveButton(req.Id);
        
        buttonExecutionClass.serviceLetterRejectButton(req.Id);
        buttonExecutionClass.serviceLetterCancelButton(req.Id);
        buttonExecutionClass.serviceLetterGenerateLetterButton(req.Id);
        buttonExecutionClass.serviceLetterConfirmManualDeliveryButton(req.Id);
        buttonExecutionClass.serviceLetterConfirmDeliveryByDeliveryDepartmentButton(req.Id);
        buttonExecutionClass.serviceLetterDeliveredButton(req.Id);
        
        
        //other buttons
        buttonExecutionClass.passwordGenerationButton(accountObject.id);
        buttonExecutionClass.submitForBackofficeApproval(accountObject.id);

        //todo
        Invoice__c invoiceObject = new Invoice__c();
        invoiceObject.Account__c = accountObject.id;
        invoiceObject.Date__c = System.Today();
        invoiceObject.Fee_Application_Type__c = 'New License';
        invoiceObject.Invoice_Type__c = 'New License';
        //Adding in the list...
        insert invoiceObject;

        //create tracking
        Tracking__c track = new Tracking__c();
        insert track;

        
        //For Receipt Object Records...
        Receipt__c receiptObject = new Receipt__c();
        receiptObject.Company__c = accountObject.id;
        receiptObject.Total_Amount_on_Invoice__c = invoiceObject.Total_Invoice_Formula_Field__c;
        receiptObject.Receipt_Type__c = invoiceObject.Invoice_Type__c;
        receiptObject.Related_Invoice__c = invoiceObject.Id;
        receiptObject.Date__c = System.Today();
        receiptObject.Cancellation_Reason__c = 'Test';
        receiptObject.is_Cancelled_Receipt__c = false;
        receiptObject.Tracking__c = track.id;
        
        insert receiptObject;

		RecordType rtEC = [select id,Name from RecordType where sObjectType=:'Application__c' and name =:'Establishment Card'];  
	      //Creating the Transaction (Code By Mustafa because of failure in the test Run)....
	    Inspection__c ins = new Inspection__c();
	    ins.Active__c = 'Yes';
	    ins.Company__c = accountObject.id;
	    insert ins;
	
	    string recordType15DigitIdEC =rtEC.Id;
	    recordType15DigitIdEC = recordType15DigitIdEC.substring(0,recordType15DigitIdEC.length()-3);
	
	    Transaction_Types__c transactionTypeEC = new Transaction_Types__c();
	    transactionTypeEC.Name = 'Establishment New';
	    transactionTypeEC.Application_Record_Type__c = rtEC.Name;
	    transactionTypeEC.Application_Record_Type_ID__c = recordType15DigitIdEC;
	    transactionTypeEC.Active__c = true;
	    insert transactionTypeEC;

  
        Application__c testappEC = new Application__c(Inspection_Number__c = ins.id,Transaction_Number__c = 'TestEC ',Transaction_Type__c = transactionTypeEC.Id, RecordType = rtEC,RecordTypeId = rtEC.id,Applicant_First_Name__c='Test',Company__c=accountObject.id);
        insert testappEC;
        
        
        buttonExecutionClass.validateContactCreationTrackingButton(track.id);
        buttonExecutionClass.slaApplicationTrackingButton(track.id, 'Tracking');
        buttonExecutionClass.slaApplicationTrackingButton(testappEC.id, 'Application');
        
        //negative test 1
        receiptObject.is_Cancelled_Receipt__c = true;
        update receiptObject; 
        buttonExecutionClass.validateContactCreationTrackingButton(track.id);
 
         //else test
        tenancyObject.Tenancy_Contract_Cancellation_Date__c = date.today();
        update tenancyObject;
        result = buttonExecutionClass.validateForAccountLicensePDFButton(accountObject.Id);
        
        fineObject.Status__c = 'Suspended';
        update fineObject;
        buttonExecutionClass.validateForAmendment(accountObject.Id);
        
        Test.startTest();
        
        //else test - invalid ids
        result = buttonExecutionClass.amendmenLicenseIssuedMethod(accountObject.Id);
        result = buttonExecutionClass.amendmenPerformaInvoiceMethod(accountObject.Id);
        result = buttonExecutionClass.amendmentEmailNotificationLicenseMethod(accountObject.Id);
        result = buttonExecutionClass.cancelEmailNotificationLicenseMethod(tenancyObject.id);
        result = buttonExecutionClass.dropLocationMethod(tenancyObject.id);
        result = buttonExecutionClass.unDropLocationMethod(tenancyObject.id);
        result = buttonExecutionClass.underVacantLocationMethod(tenancyObject.id);
        Test.stopTest();


        
        
    }
    
    static testMethod void testParse() {
        //String json='{"Transaction":{"Reference1":"001","Reference2":"1395086400","Reference3":"1395090000","Reference4":"","Reference5":""},"Notifications":{},"HasErrors":false,"ProcessedPickup":{"ID":"C187279","GUID":"a64c9fcd-d95b-4814-bdb3-c3f39f823ce8","Reference1":"0001","Reference2":"0002","ProcessedShipments":{"ProcessedShipment":{"ID":"3988595181","Reference1":"3988585296","Reference2":"","Reference3":"","ForeignHAWB":"1395154656","HasErrors":false,"Notifications":{},"ShipmentLabel":{"LabelURL":"http://www.aramex.com/content/rpt_cache/eb62570bd64d4b3c84889e01c6ba10b4.pdf","LabelFileContents":null}}}}}';
   		String json='{"Transaction":{"Reference1":"test","Reference2":"","Reference3":"","Reference4":"","Reference5":""},"Notifications":{},"HasErrors":false,"ProcessedPickup":{"ID":"H14D8DA","GUID":"1892a9c1-6734-43dd-b11d-7290084f286e","Reference1":"test","Reference2":"14/08/2014","ProcessedShipments":{"ProcessedShipment":{"ID":"30019508363","Reference1":"test","Reference2":"","Reference3":"","ForeignHAWB":"1408011209","HasErrors":false,"Notifications":{},"ShipmentLabel":{"LabelURL":"http://www.aramex.com/content/rpt_cache/59d7c0680cb44f05bef427ed2c30d1fe.pdf","LabelFileContents":null}}}}}';
        fromJSON obj = new fromJSON();
        obj = fromJSON.parse(json);
        
        //manual
        obj.Transaction_aramex = null;
        obj.Notifications.Notification = null;
        obj.ProcessedPickup.GUID='1892a9c1-6734-43dd-b11d-7290084f286e';
        obj.ProcessedPickup.ID='30019508363';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.Notifications.Notification=null;
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.ForeignHAWB='test11';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.HasErrors=false;
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.ID='test';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.Reference1 = 'test1';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.Reference2 = 'test2';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.Reference3 = 'test3';
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.ShipmentLabel.LabelFileContents = null;
        obj.ProcessedPickup.ProcessedShipments.ProcessedShipment.ShipmentLabel.LabelURL = 'http://www.aramex.com/content/rpt_cache/59d7c0680cb44f05bef427ed2c30d1fe.pdf]';
        obj.ProcessedPickup.Reference1 = 'test1';
        obj.ProcessedPickup.Reference2 = 'test2';
        
        
        system.debug(obj);
        System.assert(obj != null);

		String xml='<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:createAramexPickupResponse xmlns:ns1="urn:servicename"><sfreturn xsi:type="xsd:string">{"Transaction":{"Reference1":"test","Reference2":"","Reference3":"","Reference4":"","Reference5":""},"Notifications":{},"HasErrors":false,"ProcessedPickup":{"ID":"H14D8DA","GUID":"1892a9c1-6734-43dd-b11d-7290084f286e","Reference1":"test","Reference2":"14/08/2014","ProcessedShipments":{"ProcessedShipment":{"ID":"30019508363","Reference1":"test","Reference2":"","Reference3":"","ForeignHAWB":"1408011209","HasErrors":false,"Notifications":{},"ShipmentLabel":{"LabelURL":"http://www.aramex.com/content/rpt_cache/59d7c0680cb44f05bef427ed2c30d1fe.pdf","LabelFileContents":null}}}}}</sfreturn></ns1:createAramexPickupResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>';
		String result = Aramex_Smartpaperbpm_CreatePickup.getValueFromXMLString(xml, 'sfreturn', 0);

    }
    
}